package com.zygh.interactiveplatform.module.controller;


import com.alibaba.fastjson.JSONObject;
import com.zygh.interactiveplatform.common.anno.PcLog;
import com.zygh.interactiveplatform.common.constant.SwaggerTagConst;
import com.zygh.interactiveplatform.common.domain.ResponseDTO;
import com.zygh.interactiveplatform.module.entity.IllegalDatasource;
import com.zygh.interactiveplatform.module.entity.IllegalDatasource;
import com.zygh.interactiveplatform.module.service.IllegalDatasourceService;
import com.zygh.interactiveplatform.module.service.IllegalDatasourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lee
 * @since 2021-01-29
 */
@RestController
@RequestMapping("/illegal-datasource")
@Api(tags = {SwaggerTagConst.Admin.MANAGER_ILLEGALDATASOURCE})
public class IllegalDatasourceController {
    @Resource
    private IllegalDatasourceService illegalDatasourceService;

    @ApiOperation(value = "新增违法数据来源", notes = "新增违法数据来源")
    @PostMapping("addIllegalDatasourcee")
    @PcLog(logType = "2", module = SwaggerTagConst.Admin.MANAGER_ILLEGALDATASOURCE, content = "新增违法数据来源")
    public ResponseDTO addIllegalDatasourcee(@RequestBody @Valid IllegalDatasource illegalDatasource) {
        return illegalDatasourceService.addIllegalDatasource(illegalDatasource);
    }
    @ApiOperation(value = "修改违法数据来源", notes = "修改违法数据来源")
    @PostMapping("updateIllegalDatasource")
    @PcLog(logType = "3", module = SwaggerTagConst.Admin.MANAGER_ILLEGALDATASOURCE, content = "修改违法数据来源")
    public ResponseDTO updateIllegalDatasource(@RequestBody @Valid IllegalDatasource illegalDatasource) {
        return illegalDatasourceService.updateIllegalDatasource(illegalDatasource);
    }
    @ApiOperation(value = "删除违法数据来源", notes = "删除违法数据来源")
    @PostMapping("deleteIllegalDatasource")
    @PcLog(logType = "4", module = SwaggerTagConst.Admin.MANAGER_ILLEGALDATASOURCE, content = "删除违法数据来源")
    public ResponseDTO deleteIllegalDatasource(@RequestBody String id) {
        String s = JSONObject.parseObject(id).get("id").toString();
        Integer new_id = Integer.parseInt(s);
        return illegalDatasourceService.deleteIllegalDatasource(new_id);
    }
    @ApiOperation(value = "查询所有违法数据来源", notes = "查询所有违法数据来源")
    @GetMapping("findIllegalDatasourceAll")
    @PcLog(logType = "1", module = SwaggerTagConst.Admin.MANAGER_ILLEGALDATASOURCE, content = "查询所有违法数据来源")
    public ResponseDTO findIllegalDatasourceAll(Integer current, Integer size) {
        return illegalDatasourceService.findIllegalDatasourceAll(current,size);
    }
}
